import { getFactoryRechargeList } from '@/api/merchant'
import { ref } from 'vue'
import { GetRechargeRecordsParam } from './types'

// 加载
const loading = ref(false)

// 列表总条数
const total = ref(0)

// 获取列表方法
const get = async (data: GetRechargeRecordsParam, id: string) => {
  loading.value = true
  const res = await getFactoryRechargeList(data, id)
  if (res.data.success) {
    total.value = Number(res.data.data.total)
    loading.value = false
    return res.data.data.rows
  } else {
    loading.value = false
    if(res.data.isError)
    throw new Error(res.data.message)
  }
}

export default {
  total,
  loading,
  get,
}
